<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>

<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- jsx转为js -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

<!-- 自 React v15.5 起，React.PropTypes 已移入另一个包中。请使用 prop-types 库代替 -->
<script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>

<script type="text/babel">
    // 函数式也只能用props
    function Person(props) {
        let {name, age, sex} = props
        return (
                <ul>
                    <li>姓名：{props.name}</li>
                    <li>性别：{props.sex}</li>
                    <li>年龄：{age + 1}</li>
                </ul>
        )
    }

    // 对标签属性进行类型限制
    Person.propTypes = {
        age: PropTypes.string,
        abc: PropTypes.func // 函数
    }

    // 指定默认标签属性
    Person.defaultProps = {
        sex: "不男不女"
    }

    // 渲染一次new 一次对象
    // props属性得到 {"name": "tom"}
    ReactDOM.render(<Person name="tom1" age={18} sex="女"/>, document.getElementById("test1"))
</script>
</body>
</html>